package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * _*_ coding : utf-8 _*_
 *
 * @Time : 2023/7/31 15:41
 * @Author : 计201任思伟
 * @File : ShoppingCartMapper
 * @Project : sky-take-out
 */
@Mapper
public interface ShoppingCartMapper {
    /**
     * 动态查询 购物车数据
     * @param shoppingCart
     * @return
     */
    List<ShoppingCart> list(ShoppingCart shoppingCart);


    /**
     * 根据id修改商品数据
     * @param shoppingCart
     */
    @Update("update shopping_cart set number = #{number} where id = #{id}")
    void updateNumberById(ShoppingCart shoppingCart);

    /**
     * 插入购物车数据
     * @param shoppingCart
     */
    void insert(ShoppingCart shoppingCart);


    /**
     * 清空购物车
     * @return
     */
    @Delete("delete from shopping_cart where user_id=#{userId};")
    void deleteByUserId(Long userId);

    @Delete("delete from shopping_cart where id=#{id};")
    void deleteByNum(ShoppingCart cart);

    /**
     * 回插购物车
     * @param shoppingCartList
     */
    void insertBatch(List<ShoppingCart> shoppingCartList);
}
